﻿package com.tangrong.filesystem;

import com.tangrong.filesystem.observer.Observable;
import com.tangrong.filesystem.visitor.Visitor;

public class FileLeaf extends File implements Observable{
	
	private String content;

	public FileLeaf(){
		super();
	}
	
	public FileLeaf(String name){
		super(name);
	}

	@Override
	public void accept(Visitor v) {
		v.visit(this);
	}

	
	@Override
	public void notifyObservers() {
		logger.info("just delete file: " + this.name);
		for(Link l : this.links){
			l.update(this, "File " + this.name + "removed");
		}
	}
	
	@Override
	public void notifyObservers(Object obj) {
		this.notifyObservers();
	}
	
	@Override
	public void doSomething() {
		this.notifyObservers();
	}
	
	@Override
	public void addFile(File node) {
		throw new UnsupportedOperationException("");
	}
	
	@Override
	public void removeFile(File node) {
		throw new UnsupportedOperationException();
	}
	
	public void setContent(String content) {
		this.content = content;
	}
	public String getContent() {
		return content;
	}	
}
